//
//  YZXEmoticonButton.swift
//  表情键盘
//
//  Created by 叶周翔 on 16/7/29.
//  Copyright © 2016年 叶周翔. All rights reserved.
//

import UIKit

class YZXEmoticonButton: UIButton {
    
    var emojiconModel: YZXEmoticonModel?{
        didSet {
            
            // 按钮拿到模型 显示内容
            if let emoji = emojiconModel?.emoji {
                // 如果是emoji显示 emoji
                self.setTitle(emoji, forState: UIControlState.Normal)
                self.setImage(nil, forState: UIControlState.Normal)
            }else{
                self.setTitle(nil, forState: UIControlState.Normal)
                let image = UIImage(named: emojiconModel!.fullPngPath!)
                self.setImage(image, forState: UIControlState.Normal)
            }
            
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.titleLabel?.font = UIFont.systemFontOfSize(32)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}
